package com.cw.DesignModel23.Ceational.BuilderPattern.builder1;


/**
 * 教师类( 非必须 ) , 负责使用建造者创建学生信息
 */
public class Teacher {
    /**
     * 持有学生建造者
     */
    private StudentBuilder studentBuilder;

    /**
     * 构造函数注入建造者
     * @param studentBuilder
     */
    public Teacher(StudentBuilder studentBuilder) {
        this.studentBuilder = studentBuilder;
    }

    /**
     * 调用建造者对象创建 学生 实例对象
     * @param name
     * @param age
     * @param number
     * @param address
     * @param school
     * @return
     */
    public Student makeStudent(String name, String age,
                               String number, String address,
                               String school) {
        this.studentBuilder.buildName(name);
        this.studentBuilder.buildAge(age);
        this.studentBuilder.buildNumber(number);
        this.studentBuilder.buildAddress(address);
        this.studentBuilder.buildSchool(school);

        return this.studentBuilder.makeCourse();
    }
}
